﻿using System;
using System.Data;
using Gtk;
using mklib;

public partial class MainWindow: Gtk.Window
{
	public MainWindow () : base (Gtk.WindowType.Toplevel)
	{
		Build ();
		DataTable dt = new DataTable ();
		dt.Columns.Add ("a", typeof(int));
		dt.Columns.Add ("b", typeof(string));
		dt.Columns.Add ("c", typeof(DateTime));
		dt.Rows.Add (1, @"abc""d",DateTime.Now);
		dt.Rows.Add (2, "111\n222",DateTime.Now);
		dt.Rows.Add (2, "http://a.b.c",DateTime.Now);

		string jj = JSON.Stringify (dt
			, mklib.json.JsonDataParseType.Data
			| mklib.json.JsonDataParseType.Data
			| mklib.json.JsonDataParseType.Schema
			, false
		);

		this.textview1.Buffer.Text = jj;

		var d = JSON.ParseData (jj);
		jj = JSON.Stringify (d
			, mklib.json.JsonDataParseType.Data
			| mklib.json.JsonDataParseType.Data
			| mklib.json.JsonDataParseType.Schema
			, true
		);
		this.textview2.Buffer.Text = jj;

	}

	protected void OnDeleteEvent (object sender, DeleteEventArgs a)
	{
		Application.Quit ();
		a.RetVal = true;
	}
}
